package com.ybkj.o2o.mc.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ybkj.o2o.mc.common.query.DepartmentQuery;
import com.ybkj.o2o.mc.entity.Department;
import com.ybkj.o2o.mc.mapper.DepartmentMapper;
import com.ybkj.o2o.mc.service.DepartmentService;

@Service
public class DefaultDepartmentService implements DepartmentService{
	
	@Autowired
	private DepartmentMapper departmentMapper;

	@Override
	public Department exists(String name, String appKey, Long enterpriseId) {
		 
	    return departmentMapper.findByNameAndAppkey(name, appKey, enterpriseId);
	}

	@Override
	public int insert(Department department) {

		return departmentMapper.insert(department);
	}

	@Override
	public List<Department> findByDepartmentQuery(
			DepartmentQuery departmentQuery) {
		return departmentMapper.selectByDepartmentQuery(departmentQuery);
	}

	@Override
	public Long countByDepartmentQuery(DepartmentQuery departmentQuery) {
		return departmentMapper.countByDepartmentQuery(departmentQuery);
	}

	@Override
	public Department findByIdAndAppKey(Long id, String appKey) {
		return departmentMapper.findByIdAndAppkey(id,appKey);
	}

	@Override
	public int updateByPrimaryKey(Department department) {
		return departmentMapper.updateByPrimaryKey(department);
	}

	@Override
	public int deleteByPrimaryKey(Long id, String appKey) {
		return departmentMapper.deleteByPrimaryKey(id,appKey);
	}
	
	@Override
	public int updateBalance(Department department) {
		return departmentMapper.updateBalance(department);
	}

	@Override
	public int batchDeleteByIds(List<Long> departmentIds, String appKey) {
		return departmentMapper.batchDeleteByIds(departmentIds,appKey);
	}

	@Override
	public int updateEnterpriseNameByEnterpriseId(Long enterpriseId,
			String enterpriseName, String appKey) {
		return departmentMapper.updateEnterpriseNameByEnterpriseId(enterpriseId,enterpriseName,appKey);
	}

	@Override
	public int updateCompanyName(Long companyId, String abbreviation,
			String appKey) {
		return departmentMapper.updateCompanyName(companyId,abbreviation,appKey);
	}
	
}
